// Package rider 模型
package rider

import (
	// "gitee.com/sweetsunnyflower/carpooling-server-go/pkg/logger"
	"gitee.com/sweetsunnyflower/carpooling-server-go/app/models"
	"gitee.com/sweetsunnyflower/carpooling-server-go/pkg/database"
)

// 乘客表
type Rider struct {
	models.BaseModel
	UserId      uint64 `gorm:"column:user_id" db:"user_id" json:"user_id" form:"user_id"`
	PassengerId uint64 `gorm:"column:passenger_id" db:"passenger_id" json:"passenger_id" form:"passenger_id"`
	Name        string `gorm:"type:varchar(255)" db:"name" json:"name" form:"name"`
	Phone       string `gorm:"type:varchar(20)" db:"phone" json:"phone" form:"phone"`
	Gender      uint8  `gorm:"comment:性别 2:女,1:男;default:0;" db:"gender" json:"gender" form:"gender"`
	models.CommonTimestampsField
}

func (rider *Rider) Create() {
	database.DB.Create(&rider)
}

func (rider *Rider) Save() (rowsAffected int64) {
	result := database.DB.Save(&rider)
	return result.RowsAffected
}

func (rider *Rider) Delete() (rowsAffected int64) {
	result := database.DB.Delete(&rider)
	return result.RowsAffected
}
